package com.ating.demo.Service;

import cn.hutool.core.util.StrUtil;
import com.ating.demo.Entity.Department;
import com.ating.demo.Exceptiom.CustomException;
import com.ating.demo.Mapper.DepartmentMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DepartmentService {
    @Resource
    private DepartmentMapper departmentMapper;

    public List<Department> selectAll(Department department){
        return departmentMapper.selectAll(department);
    }

    public Department selectOne(Integer id){
        return departmentMapper.selectById(id);
    }

    public PageInfo<Department> selectPage(Integer PageSize, Integer PageNum, Department department){
        PageHelper.startPage(PageNum,PageSize);
        List<Department> list = departmentMapper.selectAll(department);
        return PageInfo.of(list);
    }

    public void add(Department department){
        departmentMapper.insert(department);
    }

    public void update(Department department){
        departmentMapper.updateById(department);
    }

    public void moveById(Integer id){
        departmentMapper.moveById(id);
    }

}
